﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace FxCopContrib.TestHarness
{
    public class ResolutionPrototype
    {
        public static ResolutionPrototype Default
        {
            get
            {
                return new ResolutionPrototype()
                {
                    Format = "*",
                    Items = null,
                    Name = "*",
                };
            }
        }

        internal bool Matches(Microsoft.FxCop.Sdk.Resolution resolution)
        {
            bool result = true;

            if (Format != null && !Format.Equals("*", StringComparison.OrdinalIgnoreCase))
            {
                result &= string.Equals(Format, resolution.Format, StringComparison.OrdinalIgnoreCase);
            }

            if (Items != null)
            {
                result &= !Items.Intersect(resolution.Items.Cast<object>()).Any();
            }

            if (Name != null && !Name.Equals("*", StringComparison.OrdinalIgnoreCase))
            {
                result &= string.Equals(Name, resolution.Name, StringComparison.OrdinalIgnoreCase);
            }
            return result;
        }

        public string Format { get; set; }

        public List<object> Items { get; set; }

        public string Name { get; set; }
    }
}
